/**
 * Created by hxpeng on 2017/4/7.
 * input為number类型时，需要自定义一个指令来格式化
 */
(function () {
    'use strict';

    angular.module('App.common')
        .directive('stringToNumber', stringToNumber);

    /** @ngInject */
    function stringToNumber() {
        return {
            require: 'ngModel',
            link: function(scope, element, attrs, ngModel) {
                ngModel.$parsers.push(function(value) {
                    return '' + value;
                });
                ngModel.$formatters.push(function(value) {
                    return parseFloat(value);
                });
            }
        };
    }

})();